package com.jh.paymentchannel.pojo;


import com.jh.paymentchannel.payment.OrderType;
import com.jh.paymentchannel.payment.PaymentUtils;
import com.jh.paymentchannel.payment.TradeStatus;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Objects;

public class PaymentView {

    private String orderNo;

    /** 用户id */

    private Long userId;

    /** 商户id **/

    private String shopId;

    /** 用户名称 */
    private String userName;

    /** 店铺简称 */
    private String merchantName;

    private String merchantId;

    /** 店铺全称 **/
    private String shopName;

    /**消费金额*/

    private BigDecimal totalAmount;

    /** 代理商分润 */
    private BigDecimal agentFee;

    /**
     * 平台分润
     */
    private BigDecimal platformFee;

    /**
     * 台卡id
     */
    private String platformCode;

    /** 商品描述 */

    private String body;

    /** 商品详情 */

    private String detail;

    /** 商品订单号 */

    private String outTradeNo;

    /** 交易号(上游返回) */

    private String tradeNo;

    /** 订单类型 */
    private String orderType;

    /** 交易状态 */
    private String tradeStatus;

    private String phone;

    private String startDate;

    private String endDate;

    private String minAmount;

    private String maxAmount;

    private Date updateTime;

    private Date createTime;

    private String selStatus;

    private String shopPhone;

    private String orderCode;

    private String orderStatus;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getMinAmount() {
        return minAmount;
    }

    public void setMinAmount(String minAmount) {
        this.minAmount = minAmount;
    }

    public String getMaxAmount() {
        return maxAmount;
    }

    public void setMaxAmount(String maxAmount) {
        this.maxAmount = maxAmount;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getAgentFee() {
        return agentFee;
    }

    public void setAgentFee(BigDecimal agentFee) {
        this.agentFee = agentFee;
    }

    public BigDecimal getPlatformFee() {
        return platformFee;
    }

    public void setPlatformFee(BigDecimal platformFee) {
        this.platformFee = platformFee;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getTradeNo() {
        return tradeNo;
    }

    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }

    public String getPlatformCode() {
        return platformCode;
    }

    public void setPlatformCode(String platformCode) {
        this.platformCode = platformCode;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public String getTradeStatus() {
        return tradeStatus;
    }

    public void setTradeStatus(String tradeStatus) {
        this.tradeStatus = tradeStatus;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    public String getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(String merchantId) {
        this.merchantId = merchantId;
    }

    public String getSelStatus() {
        return selStatus;
    }

    public void setSelStatus(String selStatus) {
        this.selStatus = selStatus;
    }

    public String getShopPhone() {
        return shopPhone;
    }

    public void setShopPhone(String shopPhone) {
        this.shopPhone = shopPhone;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public String getOrderStatus() {return orderStatus;}

    public void setOrderStatus(String orderStatus) {this.orderStatus = orderStatus;}

    @Override
    public String toString() {
        return "PaymentView{" +
                "orderNo=" + orderNo +
                ", userId=" + userId +
                ", shopId='" + shopId + '\'' +
                ", shopName='" + shopName + '\'' +
                ", totalAmount=" + totalAmount +
                ", agentFee=" + agentFee +
                ", platformFee=" + platformFee +
                ", body='" + body + '\'' +
                ", detail='" + detail + '\'' +
                ", outTradeNo='" + outTradeNo + '\'' +
                ", tradeNo='" + tradeNo + '\'' +
                ", orderType=" + orderType +
                ", tradeStatus=" + tradeStatus +
                ", updateTime=" + updateTime +
                ", createTime=" + createTime +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PaymentView that = (PaymentView) o;
        return orderNo == that.orderNo &&
                Objects.equals(userId, that.userId) &&
                Objects.equals(shopId, that.shopId) &&
                Objects.equals(shopName, that.shopName) &&
                Objects.equals(totalAmount, that.totalAmount) &&
                Objects.equals(agentFee, that.agentFee) &&
                Objects.equals(platformFee, that.platformFee) &&
                Objects.equals(body, that.body) &&
                Objects.equals(detail, that.detail) &&
                Objects.equals(outTradeNo, that.outTradeNo) &&
                Objects.equals(tradeNo, that.tradeNo) &&
                orderType == that.orderType &&
                tradeStatus == that.tradeStatus &&
                Objects.equals(updateTime, that.updateTime) &&
                Objects.equals(createTime, that.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderNo, userId, shopId, shopName, totalAmount, agentFee, platformFee, body, detail, outTradeNo, tradeNo, orderType, tradeStatus, updateTime, createTime);
    }

    public TaiwanCardOrder transform() {
        TaiwanCardOrder order = new TaiwanCardOrder();
        order.setMerchantId(getShopId());
        order.setUserId(getUserId());
        order.setMerchantName(getShopName());
        order.setShopName(getShopName());
        order.setUserName(getUserName());
        order.setOrderNo(getOrderNo());
        // 购买商品信息(待查)
        order.setBody("线下消费");
        order.setDetail("线下消费");
        order.setOrderType(OrderType.of(getOrderType()));
        order.setTradeStatus(TradeStatus.WAIT_BUYER_PAY);
        Date currDate = new Date();
        order.setUpdateTime(currDate);
        order.setCreateTime(currDate);
        return order;
    }

}
